import { createSSRApp } from 'vue';
import mitt from 'mitt';
import App from './App.vue';
import store from './store';
import util from '@/utils/util.js';
import manifest from './manifest.json';
// 1. 导入公共组件
import FloatButton from '@/components/FloatButton/index.vue';

export function createApp() {
  const app = createSSRApp(App);

  // 2. 注册全局组件
  app.component('float-button', FloatButton);

  app.use(store);
  // 配置公共方法
  app.config.globalProperties.$bus = new mitt();
  app.config.globalProperties.$util = util;
  app.config.globalProperties.$noMultipleClicks = util.noMultipleClicks;
  app.config.globalProperties.onBack = () => uni.navigateBack();
  app.config.globalProperties.$appId = manifest['mp-weixin'].appid;
  return {
    app,
  };
}
